        var ofeeListStore = new Ext.data.JsonStore({
			url: '/weihe/getSumList_feeList',
			root: 'datas',
			fields : [{
						name:'FeeId',mapping:'id'
					},{
     				    name:'FeeDate', mapping:'date',type : 'date', dateFormat:"Y-m-d"
      			  	},{
						name:'FeeType',mapping:'type'
					},{
						name:'FeeRent',mapping:'rent'
					},{
						name:'FeeWage',mapping:'wage'
				    },{
				    	name:'FeeWaterRate',mapping:'waterRate'
				    },{
				    	name:'FeeElecRate',mapping:'elecRate'
				    },{
				    	name:'FeeOfficRate',mapping:'officRate'
				    },{
				    	name:'FeeTeleRate',mapping:'teleRate'
				    },{
				    	name:'FeeDepreciation',mapping:'depreciation'
				    },{
				    	name:'FeeInterest',mapping:'interest'
				    },{
				    	name:'FeeMeal',mapping:'meal'
				    },{
				    	name:'FeeOperationRate',mapping:'operationRate'
				    },{
				    	name:'FeeGather',mapping:'gather'
				    },{
				    	name:'FeeOther',mapping:'other'
				    },{
				    	name:'FeeTwRate',mapping:'twRate'
				    },{
				    	name:'FeeSport',mapping:'sport'
				    },{
				    	name:'FeeSocial',mapping:'social'
				    },{
				    	name:'FeeEduRate',mapping:'eduRate'
				    },{
				    	name:'FeeSum',mapping:'sum'
				    }],
				    baseParams : {'feeList.type': 'oversea'},
					listeners :{ 
					   'beforeload':function(s,options) {
							var tag = 0;
							Ext.Ajax.request({
								url : '/weihe/getListJudge_feeList',
								success : function(response) {
									var json = Ext.decode(response.responseText);
									if (json.deny) {
										Ext.Msg.alert('错误',json.msg);
										tag = 1;
									}
										if(tag == 1){
											return false;
										}else{
											return true;						
										}
								},
								failure : function() {
									Ext.Msg.alert('错误', '失败!');
									tag =1;
								}
							});
			   }
			}
		});
        
        

        var ofeeStore = new Ext.data.JsonStore({
			url: '/weihe/getList_feeList',
			root: 'datas',
			fields : [{
						name:'FeeId',mapping:'id'
					},{
     				   name:'FeeDate', mapping:'date',type : 'date', dateFormat:"Y-m-d H:i:s"
      			  	},{
						name:'FeeType',mapping:'type'
					},{
						name:'FeeRent',mapping:'rent'
					},{
						name:'FeeWage',mapping:'wage'
				    },{
				    	name:'FeeWaterRate',mapping:'waterRate'
				    },{
				    	name:'FeeElecRate',mapping:'elecRate'
				    },{
				    	name:'FeeOfficRate',mapping:'officRate'
				    },{
				    	name:'FeeTeleRate',mapping:'teleRate'
				    },{
				    	name:'FeeDepreciation',mapping:'depreciation'
				    },{
				    	name:'FeeInterest',mapping:'interest'
				    },{
				    	name:'FeeMeal',mapping:'meal'
				    },{
				    	name:'FeeOperationRate',mapping:'operationRate'
				    },{
				    	name:'FeeGather',mapping:'gather'
				    },{
				    	name:'FeeOther',mapping:'other'
				    },{
				    	name:'FeeTwRate',mapping:'twRate'
				    },{
				    	name:'FeeEduRate',mapping:'eduRate'
				    },{
				    	name:'FeeSport',mapping:'sport'
				    },{
				    	name:'FeeSocial',mapping:'social'
				    },{
				    	name:'FeeSum',mapping:'sum'
				    }],
				    baseParams : {'feeList.type': 'oversea'},
					listeners :{ 
					   'beforeload':function(s,options) {
							var tag = 0;
							Ext.Ajax.request({
								url : '/weihe/getListJudge_feeList',
								success : function(response) {
									var json = Ext.decode(response.responseText);
									if (json.deny) {
										Ext.Msg.alert('错误',json.msg);
										tag = 1;
									}
										if(tag == 1){
											return false;
										}else{
											return true;						
										}
								},
								failure : function() {
									Ext.Msg.alert('错误', '失败!');
									tag =1;
								}
							});
			   }
			}
		});
    	
    	

ofees = function(){
  return{
     
	  feeListGrid : function(){

		var pageToolBar = new Ext.PagingToolbar({
			pageSize : 5,
			store : ofeeListStore,
			displayInfo : true,
			displayMsg : '当前显示{0}-{1}条记录,共{2}条记录',
		    emptyMsg : "没有记录显示!",
		    firstText : '首页',
		    prevText : '上一页',
		    nextText : '下一页',
		    lastText : '尾页',
		    beforePageText : '第',
		    afterPageText : '页,共{0}页'
		   
		});

	

		var rowSelectionModel = new Ext.grid.RowSelectionModel({singleSelect : true});
		
		 
	   var feeListGrid = new Ext.grid.GridPanel({
		   id:'feeListGrid',
		   title : '费用表',
		   region : 'north',
		   height :300,
		   minColumnWidth : 50,
		   tbar:["-",'查看年份:',new Ext.form.TextField({id:'year',name:'query',value:(new Date()).format('Y'),width:'50'}),new Ext.Button({text:'提交',handler : function() {
			   					Ext.getCmp("feeListGrid").getStore().baseParams = {'query':Ext.getCmp('year').getValue(),'feeList.type':'oversea'};
			   					Ext.getCmp("feeListGrid").getStore().load({params : {start : 0, limit : 5}});
			   					Ext.getCmp("feeGrid").getStore().removeAll();
		   		}})
		   ,"-"],

		   loadMask : {msg:'正在加载数据，请稍侯...'},
		   store : ofeeListStore,
		   columns: [
		             {header : '日期', dataIndex : 'FeeDate', menuDisabled : true,renderer:function(value){
							if(value != null){
									return value.format('Y-m');
								}else{
									return '本年累计';
								}
		             }},
		             {header : '租金', dataIndex : 'FeeRent'},
		             {header : '工资', dataIndex : 'FeeWage'},
		             {header : '水费', dataIndex : 'FeeWaterRate'},
		             {header : '电费', dataIndex : 'FeeElecRate'},
		             {header : '办公费', dataIndex : 'FeeOfficRate'},
		             {header : '电话费', dataIndex : 'FeeTeleRate'},
		             {header : '折旧', dataIndex : 'FeeDepreciation'},
		             {header : '利息', dataIndex : 'FeeInterest'},
		             {header : '福食', dataIndex : 'FeeMeal'},
		             {header : '业务费', dataIndex : 'FeeOperationRate'},
		             {header : '汇兑损益（+-）', dataIndex : 'FeeGather'},
		             {header : '教育费', dataIndex : 'FeeEduRate'},
		             {header : '运杂费', dataIndex : 'FeeSport'},
		             {header : '社保费', dataIndex : 'FeeSocial'},
		             {header : '其他', dataIndex : 'FeeOther'},
		             {header : '合计', dataIndex : 'FeeSum'}
        ],
           sm : rowSelectionModel,
           listeners :{ 
			   'rowclick':function(grid, rowIndex, event) {
			   var record = grid.getStore().getAt(rowIndex);
			  	if(record.get('FeeDate')!=null){
			  	 var d = record.get('FeeDate').format('Y-m')+"";
			  	 Ext.getCmp("feeGrid").getStore().baseParams = {'query':d,'feeList.type': 'oversea'};
			   	 Ext.getCmp("feeGrid").getStore().load({params : {start : 0, limit : 5}});
			   	}
		
			   }
		},
		  viewConfig : {
		     forceFit : false
		  },
		  bbar : pageToolBar
});
		return feeListGrid;
	},
  	 feeGrid : function(){

		var pageToolBar = new Ext.PagingToolbar({
			pageSize : 5,
			store : ofeeStore,
			displayInfo : true,
			displayMsg : '当前显示{0}-{1}条记录,共{2}条记录',
		    emptyMsg : "没有记录显示!",
		    firstText : '首页',
		    prevText : '上一页',
		    nextText : '下一页',
		    lastText : '尾页',
		    beforePageText : '第',
		    afterPageText : '页,共{0}页'
		   
		});

		var rowSelectionModel = new Ext.grid.RowSelectionModel({singleSelect : true});
		 
	   var feeGrid = new Ext.grid.GridPanel({
		   id:'feeGrid',
		   title : '费用表',
		   region : 'center',
		   minColumnWidth : 50,
		   loadMask : {msg:'正在加载数据，请稍侯...'},
		   store : ofeeStore,
		   columns: [
		             {header : '日期', dataIndex : 'FeeDate',sortable : true,renderer:Ext.util.Format.dateRenderer('Y-m-d H:i:s'),width:130},
		             {header : '租金', dataIndex : 'FeeRent'},
		             {header : '工资', dataIndex : 'FeeWage'},
		             {header : '水费', dataIndex : 'FeeWaterRate'},
		             {header : '电费', dataIndex : 'FeeElecRate'},
		             {header : '办公费', dataIndex : 'FeeOfficRate'},
		             {header : '电话费', dataIndex : 'FeeTeleRate'},
		             {header : '折旧', dataIndex : 'FeeDepreciation'},
		             {header : '利息', dataIndex : 'FeeInterest'},
		             {header : '福食', dataIndex : 'FeeMeal'},
		             {header : '业务费', dataIndex : 'FeeOperationRate'},
		             {header : '汇兑损益（+-）', dataIndex : 'FeeGather'},
		             {header : '教育费', dataIndex : 'FeeEduRate'},
		             {header : '运杂费', dataIndex : 'FeeSport'},
		             {header : '社保费', dataIndex : 'FeeSocial'},
		             {header : '其他', dataIndex : 'FeeOther'},
		             {header : '合计', dataIndex : 'FeeSum'}
        ],
           sm : rowSelectionModel,
           listeners :{ 
			   'rowclick':function(grid, rowIndex, event) {
			   var record = grid.getStore().getAt(rowIndex);
				   Ext.getCmp("feeForm").form.loadRecord(record);
				   Ext.getCmp("feeForm").buttons[0].setText('修改');
		   }
		},
		  viewConfig : {
		     forceFit : false
		  },
		  bbar : pageToolBar
});
		return feeGrid;
	},
	feeForm : function(){
		var button_add = new Ext.Button({
			text : '添加',
			handler : function() {
					progressConsole();
				if(feeForm.form.isValid()){ 	
					if (feeForm.form.findField("feeList.id").getValue() == "") {
						feeForm.form.submit({
						  url : '/weihe/add_feeList',
						   success : function(form, action) {
							  if (action.result.deny) {
									 Ext.Msg.alert('错误', action.result.msg);
							 }else{
								Ext.Msg.alert('消息', action.result.msg, function() {
			  							   var d = feeForm.form.findField("feeList.date").getValue().format('Y-m')+"";
			  	 						   Ext.getCmp("feeGrid").getStore().baseParams = {'query':d,'feeList.type': 'oversea'};
			   	 						   Ext.getCmp("feeGrid").getStore().load({params : {start : 0, limit : 5}});
									       Ext.getCmp("feeListGrid").getStore().reload();
									       feeForm.form.reset();
								});
							  }
						    }
					    });
					}else {
						feeForm.form.submit({
							  url : '/weihe/update_feeList',
							   success : function(form, action) {
								  if (action.result.deny) {
									 Ext.Msg.alert('错误', action.result.msg);
								  }else{
									Ext.Msg.alert('消息', action.result.msg, function() {
										feeForm.form.reset();
										Ext.getCmp("feeGrid").getStore().reload();
										Ext.getCmp("feeListGrid").getStore().reload();
										feeForm.buttons[0].setText('添加');
										
									});
								  }
							    }
						    });
					}
			}else{
				Ext.Msg.alert('提示','请输入相关内容');
			}
				}
		
			
		});

	var button_clear = new Ext.Button({
		id : 'button_clear',
		text : '清空',
		handler : function() {
			feeForm.form.reset();
			feeForm.buttons[0].setText('添加');
		}
	});

	var button_del = new Ext.Button({
		text : '删除',
		handler : function() {
			var id = feeForm.form.findField('feeList.id').getValue();
			if (id == '') {
				Ext.Msg.alert('提示', '请选择需要删除的信息!');
			} else {
				progressConsole();
				Ext.Ajax.request({
					url : '/weihe/delete_feeList',
					success : function(response) {
						var json = Ext.decode(response.responseText);
						if (json.success) {
							if (json.deny) {
									Ext.Msg.alert('错误',json.msg);
									feeForm.form.reset();
									feeForm.buttons[0].setText('添加');
							}else{
							Ext.Msg.alert('消息', json.msg, function() {
								Ext.getCmp("feeGrid").getStore().reload();
								Ext.getCmp("feeListGrid").getStore().reload();
								feeForm.form.reset();
								feeForm.form.findField("FeeDate").setValue((new Date()).format('Y-m-d H:i:s'));
								feeForm.buttons[0].setText('添加');
							});
						  }
						}else{
							Ext.Msg.alert('消息', json.msg);
						}
					},
					failure : function() {
						Ext.Msg.alert('错误', '删除失败!');
					},
					params : 'feeList.id=' + id
				});
			}
		}
	});
	

	var  feeForm = new Ext.form.FormPanel({
		id : 'feeForm',
		title : '费用信息',
		frame : true,
		width : 300,
		region : 'east',
		autoScroll : true,
		labelAlign : 'right',
		labelWidth : 60,
		defaultType : 'textfield',
			defaults : {
			width : 200
		},
		items : [{  
			id:'FeeId',
			xtype : 'hidden',  
			name : 'feeList.id'
		},{  
			id:'FeeType',
			xtype : 'hidden',
			name : 'feeList.type',
			value: 'oversea'
		},{
			id:'FeeDate',
			xtype: 'datetimefield',
			fieldLabel: '日期',
			name: 'feeList.date',
			value: (new Date()).format('Y-m-d H:i:s'),
			format: 'Y-m-d H:i:s'						
		},{
			id:'FeeRent',
			fieldLabel : '租金',
			name : 'feeList.rent',
			regex : /^$|^\d+(\.\d+)?$/,
		    regexText:'请输入有效的价格' 
		},{
			id:'FeeWage',
			fieldLabel : '工资',
			name : 'feeList.wage',
			regex : /^$|^\d+(\.\d+)?$/,
		    regexText:'请输入有效的价格' 
		},{
			id:'FeeWaterRate',
			fieldLabel : '水费',
			name : 'feeList.waterRate',
			regex : /^$|^\d+(\.\d+)?$/,
		    regexText:'请输入有效的价格' 
		},{
			id:'FeeElecRate',
			fieldLabel : '电费',
			name : 'feeList.elecRate',
			regex : /^$|^\d+(\.\d+)?$/,
		    regexText:'请输入有效的价格' 
		},{
			id:'FeeOfficRate',
			fieldLabel : '办公费',
			name : 'feeList.officRate',
			regex : /^$|^\d+(\.\d+)?$/,
		    regexText:'请输入有效的价格' 
		},{
			id:'FeeTeleRate',
			fieldLabel : '电话费',
			name : 'feeList.teleRate',
			regex : /^$|^\d+(\.\d+)?$/,
		    regexText:'请输入有效的价格' 
		},{
			id:'FeeDepreciation',
			fieldLabel : '折旧',
			name : 'feeList.depreciation',
			regex : /^$|^\d+(\.\d+)?$/,
		    regexText:'请输入有效的价格' 
		},{
			id:'FeeInterest',
			fieldLabel : '利息',
			name : 'feeList.interest',
			regex : /^$|^\d+(\.\d+)?$/,
		    regexText:'请输入有效的价格' 
		},{
			id:'FeeMeal',
			fieldLabel : '福食',
			name : 'feeList.meal',
			regex : /^$|^\d+(\.\d+)?$/,
		    regexText:'请输入有效的价格' 
		},{
			id:'FeeOperationRate',
			fieldLabel : '业务费',
			name : 'feeList.operationRate',
			regex : /^$|^\d+(\.\d+)?$/,
		    regexText:'请输入有效的价格' 
		},{
			id:'FeeGather',
			fieldLabel : '汇兑损益',
			name : 'feeList.gather',
			regex : /^-?\d+(\.\d+)?$/,
		    regexText:'请输入有效的价格' 
		},{
			id:'FeeTwRate',
			fieldLabel : '提围费',
			name : 'feeList.twRate',
			regex : /^$|^\d+(\.\d+)?$/,
		    regexText:'请输入有效的价格'
		},{
			id:'FeeEduRate',
			fieldLabel : '教育费',
			name : 'feeList.eduRate',
			regex : /^$|^\d+(\.\d+)?$/,
		    regexText:'请输入有效的价格' 
		},{
			id:'FeeSport',
			fieldLabel : '运杂费',
			name : 'feeList.sport',
			regex : /^$|^\d+(\.\d+)?$/,
		    regexText:'请输入有效的价格' 
		},{
			id:'FeeSocial',
			fieldLabel : '社保费',
			name : 'feeList.social',
			regex : /^$|^\d+(\.\d+)?$/,
		    regexText:'请输入有效的价格' 
		},{
			id:'FeeOther',
			fieldLabel : '其他',
			name : 'feeList.other',
			regex : /^$|^\d+(\.\d+)?$/,
		    regexText:'请输入有效的价格' 
		}],
		buttons : [button_add,button_clear,button_del]
	});
		return  feeForm;
	}
  }
}();








